package com.zl.controller;

import java.util.List;

import net.sf.json.JSON;
import net.sf.json.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zl.entity.City;
import com.zl.entity.Province;
import com.zl.service.SelectorService;
import com.zl.util.JsonMapper;

/**   
* @Title: SelectorController.java 
* @Package com.zl.controller 
* @Description: 类别控制器（包括地区，栏目）
* @author chxl   
* @date 2015年8月4日 下午3:12:37 
* @version V1.0   
*/
@Controller
@RequestMapping("selector")
@Scope("prototype")
public class SelectorController {
	
	@Autowired
	private SelectorService selectorService;
	
	/**
	 * 获得所有省
	 * @return
	 */
	@RequestMapping("province")
	public String getProvince(){
		List<Province> list = selectorService.getAllProvince();
		return "";
	}
	
	@RequestMapping("getCity")
	@ResponseBody
	public String getProvince(String provinceId){
		List<City> list = selectorService.getCity(provinceId);
		return JsonMapper.nonDefaultMapper().toJson(list);
	}
	
	@RequestMapping("getCityByName")
	@ResponseBody
	public String getCityByName(String name){
		City city = selectorService.getCityByName(name);
		return JsonMapper.nonDefaultMapper().toJson(city);
	}
}
